package com.ruirui.demo.strategy.impl;

import com.ruirui.demo.strategy.GradingStrategy;
import com.ruirui.demo.strategy.entity.Answer;
import com.ruirui.demo.strategy.entity.Question;
import org.springframework.stereotype.Component;


@Component
public class SingleChoiceStrategy implements GradingStrategy {
    @Override
    public int grade(Question question, Answer answer) {
        return question.getCorrectAnswer().equalsIgnoreCase(answer.getStudentAnswer())
                ? question.getScore() : 0;
    }
}
